package com.campusbackend.mapper;

import com.campusbackend.entity.EducationBackgrounds;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 教育背景表 Mapper 接口
 * </p>
 *
 * @author yezi
 * @since 2025-07-24
 */
@Mapper
public interface EducationBackgroundsMapper extends BaseMapper<EducationBackgrounds> {

    /**
     * 根据学生ID查询教育背景列表
     * @param studentId 学生ID
     * @return 教育背景列表
     */
    @Select("SELECT * FROM education_backgrounds WHERE student_id = #{studentId} ORDER BY start_time DESC, create_time DESC")
    List<EducationBackgrounds> selectByStudentId(Long studentId);

    /**
     * 根据教育背景ID和学生ID查询单个教育背景记录（用于权限校验）
     * @param id 教育背景ID
     * @param studentId 学生ID
     * @return 教育背景记录
     */
    @Select("SELECT * FROM education_backgrounds WHERE id = #{id} AND student_id = #{studentId}")
    EducationBackgrounds selectByIdAndStudentId(Long id, Long studentId);
}